module.exports = {
  makeRandomString(len) {
    let guid = ''
    for (let i = 1; i <= len; i++) {
      const n = Math.floor(Math.random() * 16.0).toString(16)
      guid += n
    }
    return guid
  },
  makeDBWhere(search) {
    console.log(search)
    let e = []
    for (let v in search) {
      if (typeof search[v] == 'object') {
        // if (search[v].do == 'like') {
        // } else {
        // }
        e.push(`${v} ${search[v].do} ${search[v].value}`)
      } else e.push(`${v}=${search[v]}`)
    }
    if (e.length == 0) return ''
    return 'where ' + e.join(' and ')
  },
  randomNum(min = 0, max = 10) {
    return Math.round(Math.random() * (max - min)) + min
  },
  randomAvatarUrl() {
    let a = [
      'https://tse3-mm.cn.bing.net/th/id/OIP-C.XpnLCXvNjh1PjkvAr-t6nAAAAA?w=210&h=210&c=7&r=0&o=5&pid=1.7',
      'https://tse3-mm.cn.bing.net/th/id/OIP-C.id3YItDsqVwBIiohmCogSgAAAA?w=210&h=210&c=7&r=0&o=5&pid=1.7',
      'https://tse2-mm.cn.bing.net/th/id/OIP-C.FWDygLJAzn-CRnX1xX30zwAAAA?w=210&h=210&c=7&r=0&o=5&pid=1.7',
      `https://tupian.qqw21.com/article/UploadPic/2020-5/202052623103460996.jpg`,
      'https://tupian.qqw21.com/article/UploadPic/2020-9/20209172232571440.jpg',
      'https://p.qqan.com/up/2021-6/2021612102682393.png',
      'https://tupian.qqw21.com/article/UploadPic/2020-7/202071322312980333.jpg',
      'https://p.qqan.com/up/2021-3/2021351114587563.jpg',
      'https://ts1.cn.mm.bing.net/th/id/R-C.e3050cfcfcf639f1730328457fce750f?rik=QlcndX%2bLSXM3NA&riu=http%3a%2f%2fwww.gx8899.com%2fuploads%2fallimg%2f2018030309%2fig53h33pmzi.jpg&ehk=oSWS%2fnSQTZOz0LlTTDJnXgE9eUuQU4trI74taTbzz3A%3d&risl=&pid=ImgRaw&r=0',
      'https://p.qqan.com/up/2021-4/16184547854968092.jpg'
    ]
    return a[this.randomNum(0, 9)]
  },
  checkCN(e) {
    if (/[^\x00-\xff]/g.test(e)) {
      return true
    }
    return false
  }
}
